﻿<Application 
    x:Class="Vent.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:converters="clr-namespace:Foundation.Converters;assembly=Foundation"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls">

    <!--Application Resources-->
    <Application.Resources>
        <LinearGradientBrush x:Key="RainbowBrush" StartPoint="0 0" EndPoint="0 0.6">
            <LinearGradientBrush.Transform>
                <ScaleTransform ScaleY="2.8"/>
            </LinearGradientBrush.Transform>
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFFF0000" Offset="0.0"/>
                <GradientStop Color="#FFFFFF00" Offset="0.1"/>
                <GradientStop Color="#FF00FF00" Offset="0.2"/>
                <GradientStop Color="#FF00FFFF" Offset="0.3"/>
                <GradientStop Color="#FF0000FF" Offset="0.4"/>
                <GradientStop Color="#FFFF00FF" Offset="0.5"/>
                <GradientStop Color="#FFFF0000" Offset="0.6"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <converters:BooleanConverter x:Key="OpacityConverter" OnTrue="1.0" OnFalse="0.7"/>

        <Style TargetType="Button">
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="Padding" Value="4"/>
            <Setter Property="Margin" Value="-4"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBorderBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0.3"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates"/>
                            </VisualStateManager.VisualStateGroups>
                            <Border 
                                x:Name="ButtonBackground" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                CornerRadius="0" 
                                Margin="{StaticResource PhoneTouchTargetOverhang}">
                                <ContentControl 
                                    x:Name="ContentContainer" 
                                    ContentTemplate="{TemplateBinding ContentTemplate}" 
                                    Content="{TemplateBinding Content}" 
                                    Foreground="{TemplateBinding Foreground}" 
                                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    Padding="{TemplateBinding Padding}" 
                                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="controls:Pivot">
            <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <ContentPresenter>
                            <TextBlock Text="{Binding}" FontSize="20"/>
                        </ContentPresenter>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>